function s = read_stat (file)

   ## usage:  s = read_stat (file)
   ##
   ## read station data

   global lim

   pkg load io

   ## repair dos files
   if isempty(stat(file))
      error("read_stat: %s not found", file) ;
   endif
   file = dos2unix(file) ;

   c = csv2cell(file) ;

   HD = false ;
   for j=1:columns(c)
      if !isnumeric(c{1,j}), HD = true ; endif 
   endfor
   if HD
      str = strsplit(fgetl(fid=fopen(file, "r")), ",") ;
      fclose(fid) ;
      s.ids = strtrim(str(4:end)) ;
      ##for j=4:columns(c)
      ##	 if isnumeric(c{1,j})
      ##	    c{1,j} = strtrim(num2str(c{1,j}, 10)) ;
      ##	 endif 
      ##endfor 
      ##s.ids = strtrim(c(1,4:end)) ;
      c = c(2:end,:) ;
   endif
   J = strcmp("", c) ;
   c(J) = {lim} ;
   s.id = cell2mat(c(:,1:3)) ;
   s.x = cell2mat(c(:,4:end)) ;
   s.x = lim2nan(s.x) ;

endfunction
